// **********************************************************************
//
// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************

// Ice version 3.3.0

package CustomerRelationsManagement;

/**
 *
 * @author Administrator
 */
public final class CRMPrxHelper extends Ice.ObjectPrxHelperBase implements CRMPrx
{
    /**
     *
     * @return
     */
    public customerPrx
    CreateCustomer()
    {
        return CreateCustomer(null, false);
    }

    /**
     *
     * @param __ctx
     * @return
     */
    public customerPrx
    CreateCustomer(java.util.Map<String, String> __ctx)
    {
        return CreateCustomer(__ctx, true);
    }

    @SuppressWarnings("unchecked")
    private customerPrx
    CreateCustomer(java.util.Map<String, String> __ctx, boolean __explicitCtx)
    {
        if(__explicitCtx && __ctx == null)
        {
            __ctx = _emptyContext;
        }
        int __cnt = 0;
        while(true)
        {
            Ice._ObjectDel __delBase = null;
            try
            {
                __checkTwowayOnly("CreateCustomer");
                __delBase = __getDelegate(false);
                _CRMDel __del = (_CRMDel)__delBase;
                return __del.CreateCustomer(__ctx);
            }
            catch(IceInternal.LocalExceptionWrapper __ex)
            {
                __handleExceptionWrapper(__delBase, __ex, null);
            }
            catch(Ice.LocalException __ex)
            {
                __cnt = __handleException(__delBase, __ex, null, __cnt);
            }
        }
    }

    /**
     *
     * @return
     */
    public orderPrx
    CreateOrder()
    {
        return CreateOrder(null, false);
    }

    /**
     *
     * @param __ctx
     * @return
     */
    public orderPrx
    CreateOrder(java.util.Map<String, String> __ctx)
    {
        return CreateOrder(__ctx, true);
    }

    @SuppressWarnings("unchecked")
    private orderPrx
    CreateOrder(java.util.Map<String, String> __ctx, boolean __explicitCtx)
    {
        if(__explicitCtx && __ctx == null)
        {
            __ctx = _emptyContext;
        }
        int __cnt = 0;
        while(true)
        {
            Ice._ObjectDel __delBase = null;
            try
            {
                __checkTwowayOnly("CreateOrder");
                __delBase = __getDelegate(false);
                _CRMDel __del = (_CRMDel)__delBase;
                return __del.CreateOrder(__ctx);
            }
            catch(IceInternal.LocalExceptionWrapper __ex)
            {
                __handleExceptionWrapper(__delBase, __ex, null);
            }
            catch(Ice.LocalException __ex)
            {
                __cnt = __handleException(__delBase, __ex, null, __cnt);
            }
        }
    }

    /**
     *
     * @param CustId
     * @return
     * @throws CustomerRelationsManagement.DBError
     */
    public customerPrx
    LoadCustomerById(int CustId)
        throws DBError
    {
        return LoadCustomerById(CustId, null, false);
    }

    /**
     *
     * @param CustId
     * @param __ctx
     * @return
     * @throws CustomerRelationsManagement.DBError
     */
    public customerPrx
    LoadCustomerById(int CustId, java.util.Map<String, String> __ctx)
        throws DBError
    {
        return LoadCustomerById(CustId, __ctx, true);
    }

    @SuppressWarnings("unchecked")
    private customerPrx
    LoadCustomerById(int CustId, java.util.Map<String, String> __ctx, boolean __explicitCtx)
        throws DBError
    {
        if(__explicitCtx && __ctx == null)
        {
            __ctx = _emptyContext;
        }
        int __cnt = 0;
        while(true)
        {
            Ice._ObjectDel __delBase = null;
            try
            {
                __checkTwowayOnly("LoadCustomerById");
                __delBase = __getDelegate(false);
                _CRMDel __del = (_CRMDel)__delBase;
                return __del.LoadCustomerById(CustId, __ctx);
            }
            catch(IceInternal.LocalExceptionWrapper __ex)
            {
                __handleExceptionWrapper(__delBase, __ex, null);
            }
            catch(Ice.LocalException __ex)
            {
                __cnt = __handleException(__delBase, __ex, null, __cnt);
            }
        }
    }

    /**
     *
     * @param CustName
     * @return
     * @throws CustomerRelationsManagement.DBError
     * @throws CustomerRelationsManagement.RecordNotFound
     */
    public customerPrx
    LoadCustomerByName(String CustName)
        throws DBError,
               RecordNotFound
    {
        return LoadCustomerByName(CustName, null, false);
    }

    /**
     *
     * @param CustName
     * @param __ctx
     * @return
     * @throws CustomerRelationsManagement.DBError
     * @throws CustomerRelationsManagement.RecordNotFound
     */
    public customerPrx
    LoadCustomerByName(String CustName, java.util.Map<String, String> __ctx)
        throws DBError,
               RecordNotFound
    {
        return LoadCustomerByName(CustName, __ctx, true);
    }

    @SuppressWarnings("unchecked")
    private customerPrx
    LoadCustomerByName(String CustName, java.util.Map<String, String> __ctx, boolean __explicitCtx)
        throws DBError,
               RecordNotFound
    {
        if(__explicitCtx && __ctx == null)
        {
            __ctx = _emptyContext;
        }
        int __cnt = 0;
        while(true)
        {
            Ice._ObjectDel __delBase = null;
            try
            {
                __checkTwowayOnly("LoadCustomerByName");
                __delBase = __getDelegate(false);
                _CRMDel __del = (_CRMDel)__delBase;
                return __del.LoadCustomerByName(CustName, __ctx);
            }
            catch(IceInternal.LocalExceptionWrapper __ex)
            {
                __handleExceptionWrapper(__delBase, __ex, null);
            }
            catch(Ice.LocalException __ex)
            {
                __cnt = __handleException(__delBase, __ex, null, __cnt);
            }
        }
    }

    /**
     *
     * @return
     * @throws CustomerRelationsManagement.DBError
     * @throws CustomerRelationsManagement.RecordNotFound
     */
    public orderPrx[]
    LoadNewOrders()
        throws DBError,
               RecordNotFound
    {
        return LoadNewOrders(null, false);
    }

    /**
     *
     * @param __ctx
     * @return
     * @throws CustomerRelationsManagement.DBError
     * @throws CustomerRelationsManagement.RecordNotFound
     */
    public orderPrx[]
    LoadNewOrders(java.util.Map<String, String> __ctx)
        throws DBError,
               RecordNotFound
    {
        return LoadNewOrders(__ctx, true);
    }

    @SuppressWarnings("unchecked")
    private orderPrx[]
    LoadNewOrders(java.util.Map<String, String> __ctx, boolean __explicitCtx)
        throws DBError,
               RecordNotFound
    {
        if(__explicitCtx && __ctx == null)
        {
            __ctx = _emptyContext;
        }
        int __cnt = 0;
        while(true)
        {
            Ice._ObjectDel __delBase = null;
            try
            {
                __checkTwowayOnly("LoadNewOrders");
                __delBase = __getDelegate(false);
                _CRMDel __del = (_CRMDel)__delBase;
                return __del.LoadNewOrders(__ctx);
            }
            catch(IceInternal.LocalExceptionWrapper __ex)
            {
                __handleExceptionWrapper(__delBase, __ex, null);
            }
            catch(Ice.LocalException __ex)
            {
                __cnt = __handleException(__delBase, __ex, null, __cnt);
            }
        }
    }

    /**
     *
     * @param CustId
     * @return
     * @throws CustomerRelationsManagement.DBError
     */
    public orderPrx[]
    LoadOrderByCustomer(int CustId)
        throws DBError
    {
        return LoadOrderByCustomer(CustId, null, false);
    }

    /**
     *
     * @param CustId
     * @param __ctx
     * @return
     * @throws CustomerRelationsManagement.DBError
     */
    public orderPrx[]
    LoadOrderByCustomer(int CustId, java.util.Map<String, String> __ctx)
        throws DBError
    {
        return LoadOrderByCustomer(CustId, __ctx, true);
    }

    @SuppressWarnings("unchecked")
    private orderPrx[]
    LoadOrderByCustomer(int CustId, java.util.Map<String, String> __ctx, boolean __explicitCtx)
        throws DBError
    {
        if(__explicitCtx && __ctx == null)
        {
            __ctx = _emptyContext;
        }
        int __cnt = 0;
        while(true)
        {
            Ice._ObjectDel __delBase = null;
            try
            {
                __checkTwowayOnly("LoadOrderByCustomer");
                __delBase = __getDelegate(false);
                _CRMDel __del = (_CRMDel)__delBase;
                return __del.LoadOrderByCustomer(CustId, __ctx);
            }
            catch(IceInternal.LocalExceptionWrapper __ex)
            {
                __handleExceptionWrapper(__delBase, __ex, null);
            }
            catch(Ice.LocalException __ex)
            {
                __cnt = __handleException(__delBase, __ex, null, __cnt);
            }
        }
    }

    /**
     *
     * @param OrderId
     * @return
     * @throws CustomerRelationsManagement.DBError
     * @throws CustomerRelationsManagement.RecordNotFound
     */
    public orderPrx
    LoadOrderById(int OrderId)
        throws DBError,
               RecordNotFound
    {
        return LoadOrderById(OrderId, null, false);
    }

    /**
     *
     * @param OrderId
     * @param __ctx
     * @return
     * @throws CustomerRelationsManagement.DBError
     * @throws CustomerRelationsManagement.RecordNotFound
     */
    public orderPrx
    LoadOrderById(int OrderId, java.util.Map<String, String> __ctx)
        throws DBError,
               RecordNotFound
    {
        return LoadOrderById(OrderId, __ctx, true);
    }

    @SuppressWarnings("unchecked")
    private orderPrx
    LoadOrderById(int OrderId, java.util.Map<String, String> __ctx, boolean __explicitCtx)
        throws DBError,
               RecordNotFound
    {
        if(__explicitCtx && __ctx == null)
        {
            __ctx = _emptyContext;
        }
        int __cnt = 0;
        while(true)
        {
            Ice._ObjectDel __delBase = null;
            try
            {
                __checkTwowayOnly("LoadOrderById");
                __delBase = __getDelegate(false);
                _CRMDel __del = (_CRMDel)__delBase;
                return __del.LoadOrderById(OrderId, __ctx);
            }
            catch(IceInternal.LocalExceptionWrapper __ex)
            {
                __handleExceptionWrapper(__delBase, __ex, null);
            }
            catch(Ice.LocalException __ex)
            {
                __cnt = __handleException(__delBase, __ex, null, __cnt);
            }
        }
    }

    /**
     *
     * @param __obj
     * @return
     */
    public static CRMPrx
    checkedCast(Ice.ObjectPrx __obj)
    {
        CRMPrx __d = null;
        if(__obj != null)
        {
            try
            {
                __d = (CRMPrx)__obj;
            }
            catch(ClassCastException ex)
            {
                if(__obj.ice_isA("::CustomerRelationsManagement::CRM"))
                {
                    CRMPrxHelper __h = new CRMPrxHelper();
                    __h.__copyFrom(__obj);
                    __d = __h;
                }
            }
        }
        return __d;
    }

    /**
     *
     * @param __obj
     * @param __ctx
     * @return
     */
    public static CRMPrx
    checkedCast(Ice.ObjectPrx __obj, java.util.Map<String, String> __ctx)
    {
        CRMPrx __d = null;
        if(__obj != null)
        {
            try
            {
                __d = (CRMPrx)__obj;
            }
            catch(ClassCastException ex)
            {
                if(__obj.ice_isA("::CustomerRelationsManagement::CRM", __ctx))
                {
                    CRMPrxHelper __h = new CRMPrxHelper();
                    __h.__copyFrom(__obj);
                    __d = __h;
                }
            }
        }
        return __d;
    }

    /**
     *
     * @param __obj
     * @param __facet
     * @return
     */
    public static CRMPrx
    checkedCast(Ice.ObjectPrx __obj, String __facet)
    {
        CRMPrx __d = null;
        if(__obj != null)
        {
            Ice.ObjectPrx __bb = __obj.ice_facet(__facet);
            try
            {
                if(__bb.ice_isA("::CustomerRelationsManagement::CRM"))
                {
                    CRMPrxHelper __h = new CRMPrxHelper();
                    __h.__copyFrom(__bb);
                    __d = __h;
                }
            }
            catch(Ice.FacetNotExistException ex)
            {
            }
        }
        return __d;
    }

    /**
     *
     * @param __obj
     * @param __facet
     * @param __ctx
     * @return
     */
    public static CRMPrx
    checkedCast(Ice.ObjectPrx __obj, String __facet, java.util.Map<String, String> __ctx)
    {
        CRMPrx __d = null;
        if(__obj != null)
        {
            Ice.ObjectPrx __bb = __obj.ice_facet(__facet);
            try
            {
                if(__bb.ice_isA("::CustomerRelationsManagement::CRM", __ctx))
                {
                    CRMPrxHelper __h = new CRMPrxHelper();
                    __h.__copyFrom(__bb);
                    __d = __h;
                }
            }
            catch(Ice.FacetNotExistException ex)
            {
            }
        }
        return __d;
    }

    /**
     *
     * @param __obj
     * @return
     */
    public static CRMPrx
    uncheckedCast(Ice.ObjectPrx __obj)
    {
        CRMPrx __d = null;
        if(__obj != null)
        {
            try
            {
                __d = (CRMPrx)__obj;
            }
            catch(ClassCastException ex)
            {
                CRMPrxHelper __h = new CRMPrxHelper();
                __h.__copyFrom(__obj);
                __d = __h;
            }
        }
        return __d;
    }

    /**
     *
     * @param __obj
     * @param __facet
     * @return
     */
    public static CRMPrx
    uncheckedCast(Ice.ObjectPrx __obj, String __facet)
    {
        CRMPrx __d = null;
        if(__obj != null)
        {
            Ice.ObjectPrx __bb = __obj.ice_facet(__facet);
            CRMPrxHelper __h = new CRMPrxHelper();
            __h.__copyFrom(__bb);
            __d = __h;
        }
        return __d;
    }

    /**
     *
     * @return
     */
    protected Ice._ObjectDelM
    __createDelegateM()
    {
        return new _CRMDelM();
    }

    /**
     *
     * @return
     */
    protected Ice._ObjectDelD
    __createDelegateD()
    {
        return new _CRMDelD();
    }

    /**
     *
     * @param __os
     * @param v
     */
    public static void
    __write(IceInternal.BasicStream __os, CRMPrx v)
    {
        __os.writeProxy(v);
    }

    /**
     *
     * @param __is
     * @return
     */
    public static CRMPrx
    __read(IceInternal.BasicStream __is)
    {
        Ice.ObjectPrx proxy = __is.readProxy();
        if(proxy != null)
        {
            CRMPrxHelper result = new CRMPrxHelper();
            result.__copyFrom(proxy);
            return result;
        }
        return null;
    }
}
